/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2024-03-21 15:58:22
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-03-22 09:02:34
 * @FilePath: /yt-devops/lib/pages/mine/system_set/security/change_password/change_password_view.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yt_devops/components/app_bar/app_bar_widget.dart';
import 'package:yt_devops/components/yt_button.dart';
import 'package:yt_devops/components/yt_input.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';
import 'change_password_controller.dart';

class ChangePasswordPage extends GetView<ChangePasswordController> {
  const ChangePasswordPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ChangePasswordController>(
      builder: (controller) => Scaffold(
        appBar: AppBarWidget.defaultAppBar(controller.title),
        body: Container(
          color: Colour.white,
          margin: const EdgeInsets.only(top: 10),
          padding: EdgeInsets.symmetric(horizontal: 16.w),
          child: Form(
            key: controller.formKey,
            onChanged: () => controller.textOnChange(),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                YtInput(
                  border: const UnderlineInputBorder(
                      borderSide: BorderSide(color: Colour.dividerColor)),
                  textAlign: TextAlign.left,
                  placeholderText: controller.oldHintText.tr,
                  inputTextStyle: TextStyles.f16,
                  controller: controller.oldPasswordController,
                  inputType: YtInputType.password,
                ),
                YtInput(
                  border: const UnderlineInputBorder(
                      borderSide: BorderSide(color: Colour.dividerColor)),
                  textAlign: TextAlign.left,
                  placeholderText: controller.newHintText.tr,
                  inputTextStyle: TextStyles.f16,
                  controller: controller.newPasswordController,
                  inputType: YtInputType.password,
                  errorMaxLines: 2,
                  validator: controller.validatePassword,
                ),
                YtInput(
                  border: InputBorder.none,
                  textAlign: TextAlign.left,
                  placeholderText: controller.confirmHintText.tr,
                  inputTextStyle: TextStyles.f16,
                  controller: controller.confirmPasswordController,
                  inputType: YtInputType.password,
                  validator: controller.validateSamePassword,
                ),
              ],
            ),
          ),
        ),
        bottomNavigationBar: Container(
            color: Colour.white,
            padding: const EdgeInsets.only(
              bottom: 34,
            ),
            child: BrnBottomButtonPanel(
              enableMainButton: controller.buttonEnable,
              mainButtonName: ResKey.submit.tr,
              mainButtonOnTap: controller.save,
            )),
      ),
    );
  }
}
